<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:t="http://myfaces.apache.org/tomahawk"
                template="templates/mainTemplate.xhtml">

    <ui:define name="content">
        <center>
            <h2 align="center">
                <h:outputText value="#{bundle.auctionListLabel}"/>
            </h2>
            
            <h:form>
                <rich:modalPanel id="descriptionPanel" autosized="true" moveable="true" resizeable="false">
                    <f:facet name="header">
                        <h:panelGroup>
                            <h:outputText value="#{bundle.description}"></h:outputText>
                        </h:panelGroup>
                    </f:facet>
                    <f:facet name="controls">
                        <h:panelGroup>
                            <h:graphicImage value="/img/close_panel.png" id="deshidelink" styleClass="hidelink"/>
                            <rich:componentControl for="descriptionPanel" attachTo="deshidelink" operation="hide" event="onclick"/>
                        </h:panelGroup>
                    </f:facet>
                    <center>
                        <h:panelGrid columns="2">
                            <h:outputText value="#{bundle.createAuctionName}:" style="font-weight:bold"/>
                            <h:outputText id="auctionDescriptionName" value="#{auctionBean.auction.name}" style="font-weight:bold"/>
                        </h:panelGrid>
                        <h:panelGrid columns="1">
                            <h:outputText value="#{bundle.createAuctionDescription}:"/>
                            <t:inputTextarea style="width:250px; height:200px" id="auctionDescriptionArea"
                                             value="#{auctionBean.auction.description}" readonly="true"/>
                        </h:panelGrid>
                    </center>
                </rich:modalPanel>
            </h:form>
            
            
            
            <a4j:outputPanel layout="block" style="#{frontendManager.formNextToChatStyle}">
            
                <h:form id="auctionListForm">
                    <rich:contextMenu attached="false" id="menu" submitMode="ajax">
                        <rich:menuItem id="menuAuctionName" ajaxSingle="true" value="#{auctionBean.auction.name}" style="font-weight:bold"/>
                        <rich:spacer height="20"/>
                        <rich:menuItem value="#{bundle.auctionOpenLog}" ajaxSingle="true" action="#{auctionBean.prepareOpeningLog}">
                        </rich:menuItem>
                        <rich:spacer height="20"/>
                        <rich:menuItem value="#{bundle.showGraph}" ajaxSingle="true" action="#{auctionBean.prepareOpeningLog1}">
                        </rich:menuItem>
                    </rich:contextMenu>
                    <a4j:outputPanel layout="block" style="overflow:auto">
                        <center>
                            <rich:dataTable columnsWidth="10em" rowKeyVar="row"
                                            onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                                            onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'" id="auctionList"
                                            rows="10" columnClasses="col" value="#{auctionBean.auctionList}" var="auction"
                                            binding="#{auctionBean.table}">
                                <a4j:support event="onRowContextMenu" actionListener="#{auctionBean.selectionChanged}"
                                             reRender="menuAuctionName"
                                             immediate="true" disableDefault="true">
                                    <rich:componentControl event="onbeforedomupdate" for="menu" operation="show"/>
                                </a4j:support>
                                <rich:column filterBy="#{auction.name}" filterEvent="onkeyup" sortBy="#{auction.name}" width="23%"
                                             style="text-align:left">
                                    <f:facet name="header">
                                        <h:outputText value="#{bundle.createAuctionName}"/>
                                    </f:facet>
                                    <a4j:outputPanel layout="block">
                                        <h:outputText value="#{auction.name}" style="font-size:10pt"/>
                                    </a4j:outputPanel>
                                </rich:column>
                                <rich:column width="8%" style="text-align:center">
                                    <f:facet name="header">
                                        <h:outputText value="#{bundle.createAuctionDescription}"/>
                                    </f:facet>
                                    <a4j:region renderRegionOnly="false">
                                        <a4j:commandLink ajaxSingle="true" oncomplete="#{rich:component('descriptionPanel')}.show()"
                                                         reRender="auctionDescriptionArea, auctionDescriptionName">
                                            <h:graphicImage id="descriptionLink" value="img/info.png" style="border:0"/>
                                            <f:setPropertyActionListener value="#{auction.name}" target="#{auctionBean.auction.name}"/>
                                            <f:setPropertyActionListener value="#{auction.description}"
                                                                         target="#{auctionBean.auction.description}"/>
                                            <rich:componentControl event="onclick" for="menu" operation="hide" disableDefault="true"/>
                                        </a4j:commandLink>
                                    </a4j:region>
                                </rich:column>
                            </rich:dataTable>
                            <rich:spacer height="5"/>
                            <rich:datascroller align="center" for="auctionList" maxPages="20" pageIndexVar="pageIndex" pagesVar="pages">
                                <f:facet name="pages">
                                    <h:outputText value="#{pageIndex} / #{pages}"></h:outputText>
                                </f:facet>
                            </rich:datascroller>
                            <rich:spacer height="5"/>
                            <rich:message for="auctionList" showDetail="true" styleClass="formatError">
                                <f:facet name="errorMarker">
                                    <h:graphicImage value="/img/error.png"/>
                                </f:facet>
                            </rich:message>
                        </center>
                    </a4j:outputPanel>
                </h:form>
                
            </a4j:outputPanel>
                
            
        </center>
    </ui:define>
</ui:composition>